#include "HandCursor.h"

HandCursor::HandCursor(SDL_Surface& display,char *imageIdle, char *imageAct1, char *imageAct2, char *imageAct3)
{
	mImageIdle    = GraphicsUtil::getInstance().Create_SDLSurface(imageIdle,1,1,1);
	mImageAction1 = GraphicsUtil::getInstance().Create_SDLSurface(imageAct1,1,1,1);
	mImageAction2 = GraphicsUtil::getInstance().Create_SDLSurface(imageAct2,1,1,1);
	mImageAction3 = GraphicsUtil::getInstance().Create_SDLSurface(imageAct3,1,1,1);
	mImageToDraw=mImageIdle;
	mDisplay=&display;
	mIsHold=false;
}

HandCursor::~HandCursor()
{
	//
}

void HandCursor::OnEvent(SDL_Event *Event)
{
	switch (Event->type)
    {
      case SDL_MOUSEMOTION:
		  {
				mPosCursorX=static_cast<float>(Event->motion.x);
				mPosCursorY=static_cast<float>(Event->motion.y);
		  }
           break;
      case SDL_MOUSEBUTTONDOWN:
		  mIsHold=true;
        break;
      case SDL_MOUSEBUTTONUP:
		  mIsHold=false;
		break;
	}
}

void HandCursor::Render()
{
	if(!mIsHold)
	{
		GraphicsUtil::getInstance().Render_SDLSurface(mDisplay,mImageIdle, mPosCursorX,mPosCursorY);
	}
	else
	{
		GraphicsUtil::getInstance().Render_SDLSurface(mDisplay,mImageAction2, mPosCursorX,mPosCursorY);
	}
}